package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ResDishCategory;
import com.ruoyi.system.service.IResDishCategoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 餐馆菜品分类Controller
 * 
 * @author ruoyi
 * @date 2025-06-02
 */
@RestController
@RequestMapping("/system/resdishcategory")
public class ResDishCategoryController extends BaseController
{
    @Autowired
    private IResDishCategoryService resDishCategoryService;

    /**
     * 查询餐馆菜品分类列表
     */
    @PreAuthorize("@ss.hasPermi('system:resdishcategory:list')")
    @GetMapping("/list")
    public TableDataInfo list(ResDishCategory resDishCategory)
    {
        startPage();
        List<ResDishCategory> list = resDishCategoryService.selectResDishCategoryList(resDishCategory);
        return getDataTable(list);
    }

    /**
     * 导出餐馆菜品分类列表
     */
    @PreAuthorize("@ss.hasPermi('system:resdishcategory:export')")
    @Log(title = "餐馆菜品分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ResDishCategory resDishCategory)
    {
        List<ResDishCategory> list = resDishCategoryService.selectResDishCategoryList(resDishCategory);
        ExcelUtil<ResDishCategory> util = new ExcelUtil<ResDishCategory>(ResDishCategory.class);
        util.exportExcel(response, list, "餐馆菜品分类数据");
    }

    /**
     * 获取餐馆菜品分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:resdishcategory:query')")
    @GetMapping(value = "/{dishCategoryId}")
    public AjaxResult getInfo(@PathVariable("dishCategoryId") Long dishCategoryId)
    {
        return success(resDishCategoryService.selectResDishCategoryByDishCategoryId(dishCategoryId));
    }

    /**
     * 新增餐馆菜品分类
     */
    @PreAuthorize("@ss.hasPermi('system:resdishcategory:add')")
    @Log(title = "餐馆菜品分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ResDishCategory resDishCategory)
    {
        return toAjax(resDishCategoryService.insertResDishCategory(resDishCategory));
    }

    /**
     * 修改餐馆菜品分类
     */
    @PreAuthorize("@ss.hasPermi('system:resdishcategory:edit')")
    @Log(title = "餐馆菜品分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ResDishCategory resDishCategory)
    {
        return toAjax(resDishCategoryService.updateResDishCategory(resDishCategory));
    }

    /**
     * 删除餐馆菜品分类
     */
    @PreAuthorize("@ss.hasPermi('system:resdishcategory:remove')")
    @Log(title = "餐馆菜品分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dishCategoryIds}")
    public AjaxResult remove(@PathVariable Long[] dishCategoryIds)
    {
        return toAjax(resDishCategoryService.deleteResDishCategoryByDishCategoryIds(dishCategoryIds));
    }
}
